<?php
/*
	Plugin Name: Wordpress MU Plugin Filter
	Plugin URI: http://missionsplace.com
	Description: Filter Out Specific Plugins so only the Wordpress MU Site Admin can see/activate them. Drop into the wp-content/mu-plugins directory to install.
	Version: 1.0
	Author: Aaron Edwards
	Author URI: http://missionsplace.com
	
	
	Instructions:
	Filters out specific plugins so only the Wordpress MU Site Admin can see/activate them
  on the plugins admin page. Drop into the wp-content/mu-plugins directory to install.
  To mark a plugin for filtering, add the text 'SiteAdminOnly' in the "Plugin Name:" section
  of the corresponding plugin file. For example, I would change the line for this plugin
  file from:
    Plugin Name: Wordpress MU Plugin Filter
  to:
    Plugin Name: Wordpress MU Plugin Filter: SiteAdminOnly
  Do this for all plugins you want to hide from WPMU users.
	
	
	Copyright 2008, MissionsPlace.com

	This program is free software: you can redistribute it and/or modify
    it under the terms of the GNU General Public License as published by
    the Free Software Foundation, either version 3 of the License, or
    (at your option) any later version.

    This program is distributed in the hope that it will be useful,
    but WITHOUT ANY WARRANTY; without even the implied warranty of
    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
    GNU General Public License for more details.

    You should have received a copy of the GNU General Public License
    along with this program.  If not, see <http://www.gnu.org/licenses/>.
*/

function site_admin_plugins_filter($wp_plugins) {
  if (is_site_admin()) { //return normal list if site admin
    return $wp_plugins;
  } else { //filter if not site admin
    $new_plugin_list = array();
    foreach ($wp_plugins as $file => $plugin) {
      if(strstr($plugin['Name'],'SiteAdminOnly')) { //skip if 'SiteAdminOnly' is found in Name in plugin file header
        continue;
      } else {
        $new_plugin_list[$file] = $plugin;
      }
    }
    return $new_plugin_list;
    
  }
}

add_filter('all_plugins', 'site_admin_plugins_filter'); //hook into Wordpress (This filter is called in wp-admin/plugins.php line 211)
?>